package com.ldz.elastic.task;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
import com.dangdang.ddframe.job.lite.internal.schedule.JobRegistry;
import com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController;
import com.ldz.elastic.config.JobSchedulerRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @Author: ldz
 * @Date: 2018-05-04 15:29
 */
//@Component
public class MyTestSimpleJob1 implements SimpleJob {

    @Override
    public void execute(ShardingContext shardingContext) {
        System.out.println("JobName:" + shardingContext.getJobName() + ", ShardingItem:" + shardingContext.getShardingItem() + ", " +
                "ShardingParameter:" + shardingContext.getShardingParameter() + ", " + "ShardingTotalCount:" + shardingContext.getShardingTotalCount() +
                ", " + "TaskId:" + shardingContext.getTaskId());
        System.out.println("---------------------------------------");
        /**
         * 实际开发中，有了任务总片数和当前分片项，就可以对任务进行分片执行了
         * 比如 SELECT * FROM user WHERE status = 0 AND MOD(id, shardingTotalCount) = shardingItem
         */
    }


}
